package com.qf.team2.netdisc.common.pojo.entity;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * 支付实体对象
 * 根据支付宝接口协议，其中的属性名，必须使用下划线，不能修改
 *
 * @author Simon_Wong
 * @date 2021/05/25 10:33
 */
@SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
public class AlipayOrder {

    /**
     * 商户订单号，必填
     */
    private String out_trade_no;
    /**
     * 订单名称，必填
     */
    private String subject;
    /**
     * 付款金额，必填
     */
    private BigDecimal total_amount;
    /**
     * 商品描述，可空
     */
    private String body;
    /**
     * 超时时间参数
     */
    private String timeout_express = "10m";
    /**
     * 产品编号
     */
    private String product_code = "FACE_TO_FACE_PAYMENT";

    /**
     * 支付状态
     */
    private Integer isPaid;

    public AlipayOrder() {
    }

    public AlipayOrder(String out_trade_no, String subject, BigDecimal total_amount, String body,
                       String timeout_express, String product_code, Integer isPaid) {
        this.out_trade_no = out_trade_no;
        this.subject = subject;
        this.total_amount = total_amount.setScale(2, BigDecimal.ROUND_HALF_UP);
        this.body = body;
        this.timeout_express = timeout_express;
        this.product_code = product_code;
        this.isPaid = isPaid;
    }

    public String getOut_trade_no() {
        return out_trade_no;
    }

    public void setOut_trade_no(String out_trade_no) {
        this.out_trade_no = out_trade_no;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public BigDecimal getTotal_amount() {
        return total_amount;
    }

    public void setTotal_amount(BigDecimal total_amount) {
        this.total_amount = total_amount.setScale(2, BigDecimal.ROUND_HALF_UP);
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public Integer getIsPaid() {
        return isPaid;
    }

    public void setIsPaid(Integer isPaid) {
        this.isPaid = isPaid;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        AlipayOrder that = (AlipayOrder) o;
        return out_trade_no.equals(that.out_trade_no) && subject.equals(that.subject) && total_amount
                .equals(that.total_amount) && body.equals(that.body) && timeout_express
                .equals(that.timeout_express) && product_code.equals(that.product_code) && isPaid.equals(that.isPaid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(out_trade_no, subject, total_amount, body, timeout_express, product_code, isPaid);
    }

    @Override
    public String toString() {
        return "AlipayOrder{" +
                "out_trade_no='" + out_trade_no + '\'' +
                ", subject='" + subject + '\'' +
                ", total_amount=" + total_amount +
                ", body='" + body + '\'' +
                ", timeout_express='" + timeout_express + '\'' +
                ", product_code='" + product_code + '\'' +
                ", isPaid=" + isPaid +
                '}';
    }
}
